package com.zxy.ziems.server.production.task;

import com.zxy.ziems.server.production.service.CustXyhCompletercvService;
import com.zxy.ziems.server.production.service.CustXyhProsalestoreService;
import com.zxy.ziems.server.production.service.CustXyhShipService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

@Component
@Slf4j
public class ProductionDataSyncTask {


    private CustXyhCompletercvService custXyhCompletercvService;


    private CustXyhProsalestoreService custXyhProsalestoreService;


    private CustXyhShipService custXyhShipService;

    @Autowired
    public void setCustXyhCompletercvService(CustXyhCompletercvService custXyhCompletercvService) {
        this.custXyhCompletercvService = custXyhCompletercvService;
    }

    @Autowired
    public void setCustXyhProsalestoreService(CustXyhProsalestoreService custXyhProsalestoreService) {
        this.custXyhProsalestoreService = custXyhProsalestoreService;
    }

    @Autowired
    public void setCustXyhShipService(CustXyhShipService custXyhShipService) {
        this.custXyhShipService = custXyhShipService;
    }

    @Scheduled(cron = "0 30 0 * * ?")
    public void sync() {
        LocalDate localDate = LocalDate.now().minusDays(1l);
        custXyhCompletercvService.synData(localDate);
        custXyhProsalestoreService.synData();
        custXyhShipService.synData(localDate);
    }
}
